//
//  VenueController.m
//  oc1
//
//  Created by kokuma on 2017/2/11.
//  Copyright © 2017年 kokumams. All rights reserved.
//

#import <Foundation/Foundation.h>


#import "VenueController.h"
#import "VenueCell.h"
#import "VenueBean.h"

@interface VenueController ()

@end

@implementation VenueController

- (void)viewDidLoad {
    [super viewDidLoad];
}
//需要重载的方法
- (void)setupCells{
    [self.myTableView registerClass:[VenueCell class] forCellReuseIdentifier:kCellIdentifier_VenueCell];
}

//需要重载的方法
- (void)getDataList{
    printf("getDataList");
    MPNetAPIManager *netAPI = [MPNetAPIManager sharedManager];
    if(!self.dataList){
        self.dataList = [NSMutableArray new];
    }
    NSMutableArray *originData = self.dataList;
    [originData removeAllObjects] ;
    [netAPI getVenuesByKeyword:@"1" andBlock:^(id data, NSError *error) {
        if(data){
            NSMutableArray *allData = data;
            
            // [weakSelf.dataList removeAllObjects];
            for(id temp in allData){
                VenueBean *bean = [[VenueBean alloc] initWithDictionary:temp];
               // NSLog([@(bean.id.longValue) stringValue]);
               // NSLog(bean.content);
                [originData addObject:bean];
            }
            [self.myTableView reloadData];
        }
    }];
}

//需要重载的方法
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    VenueCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_VenueCell forIndexPath:indexPath];
    // [cell layoutHeight];
    if(self.dataList){
        cell.bean = self.dataList[indexPath.row];
    }
    // __weak typeof(self) weakSelf = self;
    return cell;
    
}

//需要重载的方法
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return  [VenueCell cellHeight];
}
@end
